
//STL组件的简介
//容器，vector、list、deque、set、map
//算法，常用的算法，sort，find，copy，for+each
//迭代器：


/*这里我对vector的中常见的几种类型进行了尝试以及测试*/


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
void vector_int()
{
    vector <int> v;
    v.push_back(1);
    v.push_back(2);
    v.push_back(3);
    v.push_back(4);
    v.push_back(5);

    vector<int>::iterator pStart=v.begin();
    vector<int>::iterator pEnd  =v.end();

    while(pStart!=pEnd){
        cout<<*pStart<<" ";
        pStart++;

    }
    cout<<endl;
    // int n=count(pStart,pEnd,5);//这是什么东西
    // cout<<"n:"<<n<<endl;
}
void vector_double(){
    vector <double> v;
    v.push_back(12);
    v.push_back(23);
    v.push_back(45);
    v.push_back(83);
    vector<double>::iterator pStart=v.begin();
    vector<double>::iterator pEnd=v.end();

    while (pStart!=pEnd)
        {
        cout<<*pStart<<" ";                             
        pStart++;
        }
        cout<<endl;

    }

    void vector_string(){
        vector <string> v;
        v.push_back("test1");
        v.push_back("test2");
        v.push_back("test3");
        v.push_back("test4");
        v.push_back("test5");

        for(vector<string>::iterator pStart=v.begin();pStart!=v.end();pStart++)
        {   
            // cout<<"why i could not print string list";
            // cout<<endl;
            cout<<*pStart<<" ";
        }

        cout<<endl;     
    }

    //这里是统计老师的年纪吧
    class Teacher
    {
        public:
        Teacher(){};
        Teacher(string name,int edge):Name(name),
                                      Edge(edge){};
        ~ Teacher(){};

        void SetName(string newName){
            Name=newName;
        };
        void SetEdge(int newEdge){
            Edge=newEdge; //注意名字
        };

        //钩子数据 注意一下返回值
        inline string GetName() {return Name;};
        inline int GetEdge() {return Edge;};
        
        //成员变量
        private:
        string Name;
        int Edge;
    };


    //vector teacher
    //如果是teacher类的话，一定需要注意函数名字的返回值

    void vector_teacher(){
        vector<Teacher> v;
        Teacher t1("zhang2",25),t2("zhang3",26),t3("zhang4",33),t4("zhang",44);
        //
        v.push_back(t1);
        v.push_back(t2);
        v.push_back(t3);
        v.push_back(t4);

        vector<Teacher>::iterator pStart = v.begin();
	    vector<Teacher>::iterator pEnd = v.end();

        while (pStart!=pEnd){
           
            cout<<pStart->GetEdge()<<endl;
            pStart++;
        }

        // for(vector<Teacher>::iterator pStart=v.begin();pStart!=v.end();pStart++)
        // {   
        //     //保证只打印一次
        //     int i=0;
        //     if(i==0)
        //     {
        //         cout<<"outPut the information of some teacher"<<endl;
        //     }
        //     i++;
        //     //输出信息
        //     cout<<pStart->GetEdge()<<" "<< (*pStart).GetName()<<" "<<endl;
        
        // }
    }

int main()

{   
    //cout.setf(ios_base::fixed,ios_base::floatfield);
    // cout<<"testOut"<<endl;
    // vector_int();
    // vector_double();
    // vector_string();

    // Teacher zhang;
    // zhang.SetEdge(20);
    // zhang.SetName("zhang1");
    // zhang.GetName();
    // zhang.GetEdge();

    vector_teacher();
}